package com.example.demo.controller;

import com.example.demo.dao.UserDao;
import com.example.demo.pojo.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController {
    @Autowired
   private UserService userService;
//    @RequestMapping("/get")
//    public List<User> getUser(){
//        System.out.println(1);
//      List<User> userList = userService.login();
//        return  userList;
//    }


    @PostMapping(value = {"/h4/use"})
    public Map<String,Object> login(){
        Map map=new HashMap<String,Object>();
        List<User> userList=userService.login();
        if (userList!=null){
            map.put("success",true);
            map.put("msg","成功");
            map.put("data",userList);

        }else {
            map.put("success",false);
            map.put("msg","失败");
            map.put("data",userList);

        }
        return map;
    }
}
